<template>
  <div>
    <div class="nav">
      <p>
        <span>
          <em>{{alldata.QJ}}</em> /天
        </span>
        <i>本月请假</i>
      </p>
      <p>
        <span>
          <em>{{alldata.CC}}</em> /天
        </span>
        <i>本月出差</i>
      </p>
      <p>
        <span>
          <em>{{alldata.JB}}</em> /小时
        </span>
        <i>本月加班</i>
      </p>
      <!-- <p>
        <span>
          <em></em> /小时
        </span>
        <i>本月调休</i>
      </p>-->
      <div class="check" @click="kaoqintable()">考勤表</div>
    </div>
    <!-- 筛选 --start-->
    <div class="search_container">
      <hy-search
        ref="query"
        :searchTitle="searchTitle"
        v-model="searcher"
        :col="6"
        @search="getData(0)"
        class="hhh"
      ></hy-search>
    </div>
    <!-- 筛选 --end-->

    <!-- 表格 --start-->
    <div id="table_box1">
      <template>
        <el-table
          :data="tableData"
          style="width: 100%"
          strip
          heigh="700"
          stripe
          show-overflow-tooltip
        >
          <el-table-column prop="createOnStr" label="申请日期" width="200" align="center"></el-table-column>
          <el-table-column prop="typeStr" label="类型" align="center" width="100"></el-table-column>
          <el-table-column prop="time" label="时间" align="center"></el-table-column>
          <el-table-column prop="creater" label="申请人" width="100" align="center"></el-table-column>
          <el-table-column prop="reason" label="事由" align="center"></el-table-column>
          <el-table-column prop="stateStr" label="状态" width="100" align="center"></el-table-column>
          <el-table-column label="操作" width="300" align="center">
            <template slot-scope="scope">
              <el-button
                type="warning"
                size="mini"
                @click="ApplyDetail(scope.row.id,scope.row.type,0)"
                v-if="scope.row.paixu==1"
              >审核</el-button>
              <el-button
                type="primary"
                size="mini"
                @click="ApplyDetail(scope.row.id,scope.row.type,1)"
              >详情</el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>
    <!-- 表格 --end-->
    <div class="block">
      <el-pagination
        background
        layout="prev, pager, next"
        :current-page="current"
        :page-size="pagesize"
        @current-change="handleCurrentChange"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import search from "@/components/webSearch.vue";
import axios from "axios";
export default {
  data () {
    return {
      formInline: {
        key: "",
        time: []
      },
      searchTitle: [
        {
          type: "input",
          name: "customProductName",
          label: "输入搜索",
          placeholder: "请输入事由",
          prop: "customProductName"
        },
        {
          type: "date2",
          name: "issuanceDate",
          label: "输入时间",
          placeholder: "请选择输入时间",
          prop: "issuanceDate"
        }
      ],
      searcher: {
        customProductName: "",
        customProductNo: "",
        issuanceDate: ""
      },
      total: 0,
      current: 1,
      pagesize: 10,
      tableData: [],
      creater: 0,
      key: 0,
      alldata: {}
    };
  },
  components: {
    search
  },
  created () {
    this.creater = JSON.parse(localStorage.getItem("message")).Id;
    this.getData(0);
    this.gettotal()
  },
  methods: {
    // 首页统计数据
    gettotal () {
      var obj = { creater: this.creater };
      var objs = JSON.stringify(obj);
      let the = { index: 5, jsondata: objs }
      axios.post("/apis/PersonnelMatters.asmx/GetData", the).then(({ data }) => {
        var list = JSON.parse(data.d);
        this.alldata = list;
      });
    },
    //筛选
    onsubmit () {
      this.getlist(0);
    },
    // 分页
    handleCurrentChange (e) {
      this.getlist(e - 1);
    },
    // 详情
    ApplyDetail (e, type, shows) {
      this.$router.push({
        path: "./PersonnelHmPgXq",
        query: { e: e, type: type, shows: shows }
      });
    },
    //考勤表
    kaoqintable () {
      this.$router.push("/AttendanceSheet");
    },
    // 首页列表数据
    getData (page) {
      let start = ""; let end = "";
      if (this.searcher.issuanceDate != null && this.searcher.issuanceDate != "") { start = this.searcher.issuanceDate[0]; end = this.searcher.issuanceDate[1]; }
      let obj = {
        key: this.searcher.customProductName ? this.searcher.customProductName : "",
        start: start,
        end: end,
        pn: page,
        PerPageSize: this.pagesize
      };
      var objs = JSON.stringify(obj);
      let the = { index: 4, jsondata: objs }
      console.log(objs);
      axios.post("/apis/PersonnelMatters.asmx/GetData", the).then(({ data }) => {
        const list = JSON.parse(data.d);
        // console.log(list);
        this.total = list.count;
        this.tableData = list.data;
      });
    },
  }
};
</script>

<style lang="scss" scoped>
@import '@/assets/scss/base.scss';
.nav {
  width: 100%;
  height: 70px;
  text-align: center;
  display: flex;
  position: relative;
  p {
    height: 70px;
    width: 10%;
    margin: 0 1%;
    background: $white;
    border-radius: 5px;
    color: $Personnel;
    border: solid 1px #ccc;
    span {
      display: block;
      margin-top: 10px;
      em {
        font-weight: bold;
        font-size: 25px;
      }
    }
    i {
      font-style: normal;
    }
  }
  .check {
    height: 70px;
    width: 143px;
    // margin: 10px 0;
    position: absolute;
    right: 14px;
    line-height: 70px;
    border-radius: 5px;
    color: $Personnel;
    font-weight: bold;
    border: solid 1px $Personnel;
    cursor: pointer;
  }
  .check:hover {
    background: $Personnel;
    color: $white;
  }
}
.block {
  text-align: center;
  margin-top: 5px;
}
.search_container {
  align-items: center;
  background: $white;
  margin:10px auto;
  width: 98%;
  .search_box {
    width: 98%;
    padding-top: 5px;
  }
}
.hhh{width: 98%;margin: 0 auto;padding: 10px 0;}
.demo-form-inline {
  display: inline-block;
}

#table_box1 {
  width: 98%;
  background: $white;
  margin: 10px auto;

  p {
    display: inline-block;
  }
}
.el-form-item{margin-bottom: 0;}
</style>
<style>
#table_box1 .el-input__inner {
  border: 0;
  background: none;
}
/* #table_box1 .el-table td,
.el-table th {
  padding: 4px 0;
} */
</style>
